package com.gegao.somethinginteresting;

import android.support.multidex.MultiDexApplication;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.imagepipeline.core.ImagePipelineConfig;
import com.gegao.somethinginteresting.injects.ApplicationComponent;
import com.gegao.somethinginteresting.injects.ApplicationModule;
import com.gegao.somethinginteresting.injects.DaggerApplicationComponent;
import com.gegao.somethinginteresting.utils.fresco.FrescoConfigsBuilder;

/**
 * Created by zhangzhanzhong on 2016/03/16.
 */
public class IntertstingApplication extends MultiDexApplication {

    @Override
    public void onCreate() {
        super.onCreate();
        initFresco();
    }

    /**
     * 初始化Fresco
     */
    private void initFresco() {
        ImagePipelineConfig config = FrescoConfigsBuilder.getImagePipelineConfig(this);
        Fresco.initialize(this, config);
    }

    // 建议写在MyApplication类里
    public ApplicationComponent getApplicationComponent() {
        return DaggerApplicationComponent.builder()
                .applicationModule(new ApplicationModule((IntertstingApplication) this))
                .build();
    }
}
